package org.sky.security.support;

import org.apache.logging.log4j.Logger;
import org.sky.sys.util.BspUtils;
import org.sky.util.LogUtils;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author weifx
 * @Title: LogoutHandler
 * @ProjectName springboot-platform
 * @Description: TODO{自定义退出登录}
 * @date 2019/3/13 9:28
 * @Version 1.0
 */
public class CustomLogoutHandler extends SecurityContextLogoutHandler {
    private static Logger log = LogUtils.getLogger(CustomLogoutHandler.class);
    @Override
    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        try {
            if (null != BspUtils.getLoginUser()) {
                log.info("用户{}退出登录... ...", BspUtils.getLoginUser().getCode());
            }
        }catch (Exception e){
            log.error("用户正常退出登录失败{}",e.getMessage());
        }
    }
}
